package base.thread.state.sleep;

/**
 * @Author: my_code
 * @Create: 2020-12-07 16:58
 *
 * 倒计时
 */
public class SleepTest1 implements Runnable {

    public static void main(String[] args) {
        System.out.println("新年倒计时");
        new Thread(new SleepTest1()).start();

    }

    @Override
    public void run() {
        int num = 10;
        while (true) {
            System.out.print(num + " ");
            if (num-- == 0){
                System.out.println("\nhappy new year");
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
